<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>
    <div class="" id="app">
        <h1>{{msg}}</h1>
        <cpn1></cpn1>
        <cpn1></cpn1>
        <cpn1></cpn1>
    </div>

    <template id="tem1">
        <div>
            <h1>组件一</h1>
            <h2 @click="bindClick">{{num}}</h2>
        </div>
    </template>

    <script>
        var obj={
            num:0
        }
        new Vue({
            el:"#app",
            data:{
                msg:"main"
            },
            components:{
                cpn1:{
                    template:"#tem1",
                    data() {
                        return obj
                    },
                    methods: {
                        bindClick(){
                            this.num++
                        }
                    },
                }
            }
        })
    </script>
</body>
</html>